package com.d3works.apps.account.service.invoice.generator.batch;

import com.d3works.apps.account.db.Invoice;
import com.d3works.apps.account.db.repo.InvoiceRepository;
import com.d3works.apps.account.service.invoice.InvoiceService;
import com.d3works.apps.base.db.repo.BatchRepository;
import com.d3works.apps.base.service.administration.AbstractBatch;
import com.google.inject.Inject;

public abstract class BatchStrategy extends AbstractBatch {

  protected InvoiceService invoiceService;

  @Inject private BatchRepository batchRepo;

  @Inject protected InvoiceRepository invoiceRepo;

  protected BatchStrategy(InvoiceService invoiceService) {

    super();
    this.invoiceService = invoiceService;
  }

  protected void updateInvoice(Invoice invoice) {

    if (invoice != null) {

      invoice.addBatchSetItem(batchRepo.find(batch.getId()));
      incrementDone();
    }
  }

  protected void setBatchTypeSelect() {
    this.batch.setBatchTypeSelect(BatchRepository.BATCH_TYPE_INVOICE_BATCH);
  }
}
